package edu.utn.tacs.grupouno.ui.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel;

public class NavigationBar extends HorizontalPanel {

	protected Panel panel;
	protected enum MenuItems {
		Paciente {
			@Override
			public Panel getPanel() {
				return new PacientesPanel();
			}
			
			@Override
			public String getDisplayName() {
				return "Pacientes";
			}
		},
		Turno {
			@Override
			public Panel getPanel() {
				return new TurnoSelectionPanel();
			}
			
			@Override
			public String getDisplayName() {
				return "Turno";
			}
		},
		;
		
		public abstract Panel getPanel();
		public abstract String getDisplayName();
	};
	
	public NavigationBar(Panel panel) {
		this.panel = panel;
		initComponents();
	}
	
	private void initComponents() {
		setSpacing(10);
		for (final MenuItems item : MenuItems.values()) {
			Button button = new Button(item.getDisplayName());
			add(button);
			button.addClickHandler(new ClickHandler() {
				@Override
				public void onClick(ClickEvent arg0) {
					panel.clear();
					panel.add(item.getPanel());
				}
			});
		}
	}
}